import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import './pages/register.dart';
import './pages/room_detail/index.dart';
import './pages/not_found.dart';
import './pages/home/index.dart';
import './pages/login.dart';
import './pages/room_manager/index.dart';
import './pages/room_add/index.dart';
import 'setting.dart';

class Routes {
  //1、定义路由名称
  static String home = '/';
  static String login = '/login';
  static String register = '/register';
  static String roomdetail = '/roomdetail/:roomId';
  static String setting = '/setting';
  static String roomManager = '/roomManager';
  static String roomAdd = '/roomAdd';
  //2、定义路由处理函数
  static Handler _homeHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return HomePage();
  });

  static Handler _loginHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return LoginPage();
  });

  static Handler _registerHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RegisterPage();
  });

  static Handler _roomDetailHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RoomDetailPage(roomId: params['roomId'][0],);
  });

  static Handler _NotFoundHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return NotFoundPage();
  });

  static Handler _settingHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return SettingPage();
  });

  static Handler _roomManagerHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RoomManagerPage();
  });

  static Handler _roomAddHandler = Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RoomAddPage();
  });

  //3、编写函数configureRoutes关联路由名称和处理函数
  static void configureRoutes(FluroRouter router) {
    router.define(home, handler: _homeHandler);
    router.define(login, handler: _loginHandler);
    router.define(register, handler: _registerHandler);
    router.define(roomdetail, handler: _roomDetailHandler);
    router.define(setting, handler: _settingHandler);
    router.define(roomManager, handler: _roomManagerHandler);
    router.define(roomAdd, handler: _roomAddHandler);
    router.notFoundHandler = _NotFoundHandler;
  }

}